package store.lunangangster.engine.impl.bpmn.behavior;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import store.lunangangster.bpmn.model.BoundaryEvent;
import store.lunangangster.bpmn.model.definition.MessageEventDefinition;
import store.lunangangster.engine.impl.entity.ExecutionEntity;
import store.lunangangster.engine.impl.helper.MessageHelper;

public class BoundaryMessageEventBehavior extends EventBehavior {

  private static final Logger log = LoggerFactory.getLogger(BoundaryMessageEventBehavior.class);

  @Override
  public void doBehavior(ExecutionEntity execution) {
    BoundaryEvent boundaryMessageEvent = (BoundaryEvent) execution.getCurrentFlowElement();
    MessageEventDefinition messageEventDefinition = (MessageEventDefinition) boundaryMessageEvent.getEventDefinitions().get(0);

    MessageHelper.sendMessage(messageEventDefinition, execution);
    log.debug("{}发送Message", boundaryMessageEvent);
  }
}
